<template>
  <div style="display: flex;flex-direction: column;width: 100%">
    <Header :activeName="activeName"></Header>
    <div style="display: flex;margin-top: 90px;height: 30px;line-height: 30px;justify-content: center;">
      <el-breadcrumb :separator-icon="ArrowRight" style="height: 30px;width: 80%;align-items: center;line-height: 30px">
        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item>个人中心</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <main class="main">
      <div class="p-m">
        <el-menu
            background-color="#fbf8f8"
            :default-active="sideBarActiveName"
            :router="true"
            @open="handleOpen"
            @close="handleClose"
            style="border-right: none;">
          <el-sub-menu index="1">
            <template #title>
              <el-icon><location /></el-icon>
              <span>个人信息</span>
            </template>
              <el-menu-item index="/profile/setPassword">
                <template #title>
                <el-icon><Edit /></el-icon>
                <span>修改密码</span>
              </template>
              </el-menu-item>
            <el-menu-item index="/profile/updateProfile">
              <template #title>
                <el-icon><EditPen /></el-icon>
                <span>修改资料</span>
              </template>
            </el-menu-item>
          </el-sub-menu>
          <el-menu-item index="/profile/fitnessPlan">
            <el-icon><icon-documentation /></el-icon>
            <el-badge value="推荐">
              <div>健身计划</div>
            </el-badge>
          </el-menu-item>
          <el-menu-item index="/profile/myReservation">
            <el-icon><icon-documentation /></el-icon>
            <span>我的预约</span>
          </el-menu-item>
          <el-menu-item index="/profile/myCourse">
            <el-icon><icon-menu /></el-icon>
            <span>我的课程</span>
          </el-menu-item>
          <el-menu-item index="/profile/myMessage">
            <el-icon><Message /></el-icon>
            <span>消息中心</span>
          </el-menu-item>
          <el-sub-menu index="2">
            <template #title>
              <el-icon><Bell /></el-icon>
              <span>我的钱包</span>
            </template>
            <el-menu-item index="/profile/myWallet">
              <el-icon><Message /></el-icon>
              <span>钱包充值</span>
            </el-menu-item>
            <el-menu-item index="/profile/historyBilling">
              <el-icon><Message /></el-icon>
              <span>历史账单</span>
            </el-menu-item>
          </el-sub-menu>

        </el-menu>
      </div>
      <div class="p-c">
        <router-view></router-view>
      </div>
    </main>
    <BackTop></BackTop>
    <Footer></Footer>
  </div>
</template>
<script setup lang="ts">

import {ArrowRight} from "@element-plus/icons-vue";
import Header from "@/components/header/Header.vue";
import Footer from "@/components/header/Footer.vue";
import {useRouter} from "vue-router";
import BackTop from "@/components/BackTop.vue";
import {
  Document,
  Menu as IconMenu,
  Location,
  Bell,
  Edit,
  Message,
  EditPen

} from '@element-plus/icons-vue'
import {ref} from "vue";
import IconDocumentation from "@/components/icons/IconDocumentation.vue";
const handleOpen = (key: string, keyPath: string[]) => {
  sideBarActiveName.value = key
}
const handleClose = (key: string, keyPath: string[]) => {
  console.log(key, keyPath)
}
const router = useRouter()
const activeName = router.currentRoute.value.path
const sideBarActiveName = ref('/profile/myCourse');

</script>
<style scoped>
.main {
  width: 80%;
  position: relative;
  top: 20px;
  margin: auto;
  min-height: 731px;
  display: flex;
  background: #fbf8f8;
  border-top: 1px solid #000;
  border-bottom: 1px solid #ccc;
}
.p-m{
  width: 10%;
  border-right: 1px solid #ccc;
  min-height: 731px;
}
.el-submenu{
  display: flex;
  justify-content: space-between;
}
.el-menu-item {
  flex-grow: 1;
}
.p-c{
  flex-grow: 1;
  display: flex;
  justify-content: center;
}
</style>